home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 9
/
Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO
/
033a
/
medit_.zip
/
MOUSE.DOC
< prev
Wrap
Text File
|
1993-04-24
|
4KB
|
90 lines
MEDIT! Graphics Mode Mouse Cursor Editor Program
Robert Brower @1993
MOUSE.DOC function call: void mouse(int ax, int bx, int cx, int dx);
explained.
You received this program and these files because you were probably
interested in programming the IBM PC mouse. This can be a great skill
to aquire. The mouse enhances any program that uses it. Let me start
by explaining how mouse() works.
mouse() accepts 4 integer arguments as you can see from the prototype
above. It sets the CPU general purpose registers AX, BX, CX & DX to
the values that you use in the function call. It generates a software
interrupt. Once this happens the computer will stick values into these
general purpose registers so you can read them and get status. This is
accomplished by means of 4 global integer variables which I have defined
as: Max, Mbx, Mcx, and Mdx. Each time you call mouse() these variables
will contain new status concerning the call you made. This allows you
to call several functions of the mouse driver by simply setting the
argument ax to a certain value and inserting other neccessary arguments
in the mouse() call. The following list summarizes most of the more useful
functions. And tells you what you need to se the arguments to for each one.
ax=0 bx=0 cx=0 dx=0
This function will initialize the mouse. It's the first step in using
any of the other functions of the mouse driver and must be done prior
to performing any other functions. The values of bx, cx, & dx are actually
ignored so you really don't need to set them to 0, but I do for clarity.
Max will equal -1 when the mouse harware and driver are detected. Other-
wise, Max will equal 0. The number of buttons available is returned in Mbx.
ax=1 bx=0 cx=0 dx=0
This may be your next step in using the mouse. It displays it on the
screen. It will appear as a box in text modes, and as an arrow in graphics
modes. Again, bx, cx & dx are ignored. There is no output when this
function is called other than the mouse being displayed.
ax=2 bx=0 cx=0 dx=0
This function is similar to the previous one, except that this will hide
the mouse. It is still active but it's hidden. This is useful when screen
writes are taking place as the mouse will AND & XOR with pixels written
and could cause irratic looking results. So hide it when you are writing
to the screen and display it when you're finished.
ax=3 bx=0 cx=0 dx=0
The X coordinate in pixels is returned in Mcx and the Y coordinate is
returned in Mdx when this one is called. In 320 x 200 graphics mode,
divide these returned coordinates by 2 to reflect the actual screen
coordinates of the mouse cursor. If a mouse button was pressed since the
last call to mouse() then Mbx will contain the button status where:
bit 0=1: left button was pressed
bit 1=1: right button was pressed
bit 2=1: center button was pressed
bit 3-15: unused
ax=4 bx=0 cx=X coordinate dx=Y coordinate
Calling this function puts the mouse cursor at the X,Y location
specified by your cx and dx arguments respectively. bx is ignored.
ax=5 bx=0, 1 or 2 cx=0 dx=0
When you use this function, it will return the number of times the specified
mouse button was pressed where bx is:
0 left
1 right
2 center
Mbx will hold the number of times the specified button was pressed since
the last call to mouse(). Mcx and Mdx will hold the X,Y coordinates of
the locations where the last button press took place.
ax=6 bx=0, 1 or 2 cx=0 dx=0
Similar to previous call only this applies to button releases instead
of presses.
ax=7 bx=0 cx=minimum x dx=maximum x
This call sets horizontal screen limits in which the mouse will be
restricted to. cx and dx are the left and right limits in pixels
respectively.
ax=8 bx=0 cx=minimum y dx=maximum y
This call is similar to the previous call only it applies to vertical
restriction of the mouse cursor.
There are a few more, more complicated routines that are available. This
should provide a healthy start to mouse programming. However if you need
further information, I can be reached on Structures BBS in Toronto, ONT.
in the C Programmers Conference. (416) 778-4193.
Robert Brower